﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable ht = new Hashtable();

            ht.Add(1, "one");
            ht.Add(2, "two");
            ht.Add(3, "three");
            ht.Add(4, "four");

            Console.WriteLine("输入编号：");
            int id = int.Parse(Console.ReadLine());
            bool flag = ht.ContainsKey(id);

            if (flag)
            {
                Console.WriteLine("该编号代表：{0}", ht[id].ToString());
            }
            else
            {
                Console.WriteLine("该编号不存在!");
            }

            Console.WriteLine("所有编号内容如下：");

            foreach (DictionaryEntry a in ht)
            {
                int key = (int)a.Key;
                string value = a.Value.ToString();
                Console.WriteLine("编号：{0}，内容为：{1}", key, value);
            }

        }
    }
}
